using AutoMapper;
using Pay.DTO;
using Pay.IService;
using Pay.Core;
using Pay.Data;

namespace Pay.Service.AutoMapper {
	public class LogisticsMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public LogisticsMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
        protected virtual void Create()
        {
            _cfg.CreateMap<Logistics, logistics_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.flightno, src => src.MapFrom(c => c.FlightNO))
                .ForMember(dest => dest.logisticsno, src => src.MapFrom(c => c.LogisticsNO))
                .ForMember(dest => dest.pay_info, src => src.MapFrom(c => c.PayInfo))
                .ForMember(dest => dest.payid, src => src.MapFrom(c => c.PayId))
                .ForMember(dest => dest.postalno, src => src.MapFrom(c => c.PostalNO))
                .ForMember(dest => dest.logisticsstatus, src => src.MapFrom(c => c.LogisticsStatus))
                 .ForMember(dest => dest.logisticstime, src => src.MapFrom(c => c.LogisticsTime.ToDateTime()));



            _cfg.CreateMap<logistics_dto, Logistics>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.FlightNO, src => src.MapFrom(c => c.flightno))
                .ForMember(dest => dest.LogisticsNO, src => src.MapFrom(c => c.logisticsno))
                .ForMember(dest => dest.PayInfo, src => src.MapFrom(c => c.pay_info))
                .ForMember(dest => dest.PayId, src => src.MapFrom(c => c.payid))
                .ForMember(dest => dest.PostalNO, src => src.MapFrom(c => c.postalno))
                .ForMember(dest => dest.LogisticsStatus, src => src.MapFrom(c => c.logisticsstatus))
                .ForMember(dest => dest.LogisticsTime, src => src.MapFrom(c => c.logisticstime.ToUnix()));
        }
	}
}
